--至高之术
local zhigaozhishu = fk.CreateSkill {
    name = "mcdh_zhigaozhishu"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

zhigaozhishu:addEffect(fk.TargetSpecified,{
    can_trigger = function(self, event, target, player, data)
            return  player:hasSkill(self) and player == target and data.card.is_damage_card and data.firstTarget
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local targets = room:askToChoosePlayers(player,
         {
            targets = data:getAllTargets(),
            min_num = 1,
            max_num = 1,
            prompt = "#mcdh_zhigaozhishu-invoke",
            skill_name = self.name,
            cancelable = true
        })
        if #targets > 0 then
            self.cost_data = targets[1]
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to = self.cost_data
        local  card  = to:getCardIds(Player.Hand)
        if #card > 0 then
            player:showCards(card)
        end
        local flag = false
        for _, id in ipairs(card) do
            if Fk:getCardById(id).trueName == "jink" then
                flag = true
                break
            end
        end
        if flag then
            local id = room:askForCardChosen(player, to, {card_data = { { "$Hand", to:getCardIds(Player.Hand) } } }, self.name)
            room:throwCard(id, self.name, to, player)
        else
            to:drawCards(1, self.name)
        end

    end
})

zhigaozhishu:addEffect(fk.TargetConfirmed,{
    can_trigger = function(self, event, target, player, data)
        return  player:hasSkill(self) and player == target and data.card.is_damage_card
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local targets = room:askToChoosePlayers(player,
        {
           targets = data:getAllTargets(),
           min_num = 1,
           max_num = 1,
           prompt = "#mcdh_zhigaozhishu-invoke",
           skill_name = self.name,
           cancelable = true
       })
       if #targets > 0 then
        self.cost_data = targets[1]
        return true
    end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to = self.cost_data
        local  card  = to:getCardIds(Player.Hand)
        if #card > 0 then
            player:showCards(card)
        end
        local flag = false
        for _, id in ipairs(card) do
            if Fk:getCardById(id).trueName == "jink" then
                flag = true
                break
            end
        end
        if flag then
            local id = room:askForCardChosen(player, to, {card_data = { { "$Hand", to:getCardIds(Player.Hand) } } }, self.name)
            room:throwCard(id, self.name, to, player)
        else
            to:drawCards(1, self.name)
        end

    end
})

Fk:loadTranslationTable {
    ["mcdh_zhigaozhishu"] = "至高之术",
    [":mcdh_zhigaozhishu"] = "当你使用伤害牌指定目标后，或你成为伤害牌的目标后，你可以展示其中一名目标角色的手牌（无则不展示）。若其中有【闪】，你弃置其中一张牌；否则其摸一张牌。",
    ["#mcdh_zhigaozhishu-invoke"] = "至高之术:选择一名目标角色"
}

return zhigaozhishu